﻿using System;
using Controls = MahApps.Metro.Controls;

namespace DailyFx.UI
{

	public interface IFlyout 
	{
		/// <summary>
		///		<see cref="MahApps.Metro.Controls.Flyout.Header"/>
		/// </summary>
		String Header { get; }

		/// <summary>
		///		<see cref="MahApps.Metro.Controls.Flyout.Position"/>
		/// </summary>
		Controls.Position Position { get; }

		/// <summary>
		///		<see cref="MahApps.Metro.Controls.Flyout.IsOpen"/>
		/// </summary>
		Boolean IsOpen { get; }


		/// <summary>
		///		Toggles the flyout on/off
		/// </summary>
		void TrySwitch ();

	}

	public abstract class Flyout : NotifyPropertyChanged, IFlyout
	{
		/// <summary>
		///		flyout's header .
		/// </summary>
		private String header;

		/// <summary>
		///		flyout's dock position
		/// </summary>
		private Controls.Position position;

		/// <summary>
		///		is flyout opened .
		/// </summary>
		private Boolean isOpen = false ;



		public String Header
		{
			get
			{
				return this.header;
			}
			set
			{
				if (value != this.header)
				{
					this.header = value;
					this.RaisePropertyChanged ( () => this.Header);
				}
			}
		}
		public Controls.Position Position
		{
			get
			{
				return this.position;
			}
			set
			{
				if (value != this.position)
				{
					this.position = value;
					this.RaisePropertyChanged( () => this.Position);
				}
			}
		}
		public bool IsOpen
		{
			get
			{
				return this.isOpen;
			}

			set
			{
				if ( !value.Equals(this.isOpen) )
				{
					this.isOpen = value;
					this.RaisePropertyChanged(() => this.IsOpen);
				}
			}
		}

		public void TrySwitch()
		{
			this.IsOpen = !this.IsOpen;
		}
	}

}
